<template>
  <div class="goodsadd">
    <div class="head">
      <el-row>
        <el-col :span="6">
          <el-input v-model="input" placeholder="输入商品编号查询" prefix-icon="el-icon-search" clearable></el-input>
        </el-col>
        <el-col :span="2">
          <el-button type="primary">查询</el-button>
        </el-col>
        <el-col :span="6">
          <el-input v-model="input2" placeholder="商品分类" prefix-icon="el-icon-search" clearable></el-input>
        </el-col>
        <el-col :span="2">
          <el-button type="primary">查询</el-button>
        </el-col>
        <el-col :span="8">
          <el-button type="primary" @click="addinfo">批量添加</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="content">
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="日期" width="120">
          <template slot-scope="scope">{{ scope.row.date }}</template>
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="120"></el-table-column>
        <el-table-column prop="zip" label="零售价" width="120"></el-table-column>
        <el-table-column prop="zip" label="销售类型" width="120"></el-table-column>
        <el-table-column prop="zip" label="商品分类" width="120"></el-table-column>
        <el-table-column prop="zip" label="销售类型" width="120"></el-table-column>
        <el-table-column prop="zip" label="商品分类" width="120"></el-table-column>
        <el-table-column prop="zip" label="销售类型" width="120"></el-table-column>
        <el-table-column prop="zip" label="商品分类" width="120"></el-table-column>
        
        <el-table-column prop="zip" label="库存" width="120"></el-table-column>
        <el-table-column prop="address" label="詳情">
          <template slot-scope="scope">
            <a href="javascript:;"   @click="goInfo(scope.$index, scope.row)" size="small">查看</a>
          </template>
        </el-table-column>
      </el-table>     
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      input: "",
      input2: "",
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },{
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
          zip:"詳情"
        },
      ],
      multipleSelection: []
    };
  },
  methods: {
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    goInfo(index, row) {
    //点击进去详情
      console.log(index, row, row.date);
      this.$router.push({ name:"goodsinfo",params:{id:index} });
    },
    addinfo(){
      //添加信息
      this.$router.push({ name:"goodsAddInfo" });
    }
  }
};
</script>
<style lang="scss"  coped>
body {
    margin: 0;
  }
.goodsadd {
  padding: 20px 10px;
  min-height: 500px;
  background: #fff;
  border-radius: 15px;
  .head {
    padding-bottom: 20px;
    border-bottom: 1px solid #ccc;
    .el-input,
    button {
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
    }
  }
}
</style>